home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
163_02
/
swab.c
< prev
next >
Wrap
Text File
|
1988-01-30
|
640b
|
16 lines
#include <errno.h>
extern int abort();
/*
** copy nbytes between from and to, swapping odd and even bytes in the process
*/
swab(from, to, nbytes) char *from, *to; int nbytes; {
char temp;
if(nbytes & 1) abort(EINVAL); /* nbytes must be even */
nbytes >>= 1; /* get count in halfwords */
while(nbytes--) {
temp = *from++; /* temp allows copy to self */
*to++ = *from++;
*to++ = temp;
}
}